package com.xl.operator;

/**
 * @ClassDescription:
 * @JdkVersion: 1.8
 * @Author: lei·xie
 * @Created: 2024/3/12 0012 11:37
 */
public class OperatorDemo {
    public static void main(String[] args) {
        int a = 10;
        int b = 2;
        System.out.println(a+b);
        System.out.println(a-b);
        System.out.println(a*b);
        System.out.println(a/b);
        System.out.println(5/2); //2
        System.out.println(5.0/2); //转换为最高数据类型double类型再计算 2.5
        int i = 5;
        int j = 2;
        System.out.println(1.0 * i / j); //通过*1.0转换为double类型再计算 2.5
        System.out.println(a % b); //0
        System.out.println(3 % 2); //1

        System.out.println("----------------------------");

        //连接符的情况
        int a2 = 5;
        System.out.println("abc"+a2); //abc5
        System.out.println(a2+5); //10
        System.out.println("abc"+a2+'a'); //abc5a
        System.out.println(a2+'a'+"abc"); //5+97+abc=102abc 可以先计算a2+'a'，然后在计算'abc'，所以结果是102abc
    }
}
